package com.sezi.util;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;

import com.sezi.vo.page.DataPageVo;

public class DataPageUtil {
	
	public static PageRequest getPage(DataPageVo vo){
		
		Sort sort = null;
		if(!StringUtils.isEmpty(vo.getSort())){
			if(!StringUtils.isEmpty(vo.getOrder())){
				sort = new Sort(Direction.valueOf(vo.getOrder()),vo.getSort());
			}else{
				sort = new Sort(Sort.DEFAULT_DIRECTION,vo.getSort());
			}
		}
		PageRequest request = new PageRequest(vo.getPageNo(),vo.getPageSize(),sort);
		return request;
	}
	
}
